/**
 * File : RedisConfigUtils.java <br/>
 * Author : xuehj <br/>
 * Version : 1.1 <br/>
 * Date : 2017年3月21日 <br/>
 * Modify : <br/>
 * Package Name : com.yuju.init.cache.config <br/>
 * Description : <br/>
 * 
 */

package com.yuju.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * ClassName : ConfigUtils <br/>
 * Function : 配置文件部分读取. <br/>
 * Reason : 配置文件部分读取. <br/>
 * Date : 2017年3月21日 上午10:04:08 <br/>
 * 
 * @author : xuehj <br/>
 * @see
 */

public class ConfigUtils {

	private static ConfigUtils systemConfigUtil = null;
	private static Map<String, String> proMap = new HashMap<String, String>();

	private ConfigUtils(String filter) {
		InputStream is = null;
		Properties pro = new Properties();

		try {
			is = Thread.currentThread().
					getContextClassLoader().
					getResourceAsStream("/resource/resource-" + filter + ".properties");
			pro.load(is);
			Enumeration e = pro.propertyNames();
			while (e.hasMoreElements()) {
				String key = (String) e.nextElement();
				String value = (String) pro.get(key);
				proMap.put(key, value);
			}
		}catch (IOException e) {
			e.printStackTrace();
		}finally {
			try {
				is.close();// 千万别忘了关闭资源哦！
			}catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	public static ConfigUtils getInstance(String filter) {
		if (systemConfigUtil == null) {
			systemConfigUtil = new ConfigUtils(filter);
		}
		return null;
	}

	public static Map<String, String> getProMap() {
		return proMap;
	}
}
